<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
    <script>
        //ES5  构造函数 + 原型  
        
        //Person  name age  sayName

        // function Person(name,age){
        //     this.name = name;
        //     this.age = age;
        // }

        // Person.prototype.sayName = function(){
        //     console.log(this.name);
        // }

        // Person.prototype.setName = function(name){
        //     this.name = name;
        // }

        // // ES5 继承

        // function Student(){
        //     Person.apply(this,arguments);
        // }

        // Student.prototype = Object.create(Person.prototype);

        // Student.prototype.constructor = Student;

        // console.log(new Student());
        // var student1 = new Student('lisi');
        // student1.sayName();


        // //调用

        // var p1 = new Person('lili',18);

        // p1.sayName();

        //ES6 class  语法糖

        /**
            class Person{
                只能写方法,方法和方法之间不能写逗号，不能写属性

                constructor(){  //默认方法,自动执行  如果没写constructor方法,默认会添加上

                }   
            }     
        */

        class Person{
            constructor(name,age){
                this.name = name;
                this.age = age;
            }
            // a = 10;

            sayName(){
                alert('11')
            }

            setName(name){
                this.name = name;
            }

            static play(){          //静态方法在实例上调不到，需要使用类调
                console.log(this.name)
                console.log("玩")
            }

            // static a = 10;          //静态属性，需要使用类调

        }

        // console.log(typeof Person);

        // let p1 = new Person('zhangsan',10);
        // p1.sayName();

        // console.log(p1);
        // Person.play();
        // console.log(Person.a);


        class Student extends Person{
            constructor(name,age){
                super(name,age)
            }

            learn(){
                console.log("写作业")
            }
        }

        let stu1 = new Student('oo');
        stu1.sayName();

        stu1.learn();

        Student.play();
</script>
</body>
</html>